
import React,{PropTypes,Component,PureComponent}  from 'react';
import {Select ,Button ,Tree ,Modal, Form, Input, TreeSelect,Row,Col } from 'antd';
import { connect } from 'dva';
import SchemeSetup from './schemeSetup';
// import SchemeSetup from './set';
import style from './planSelect.less';
import SchememFit from './schememFit';//筛选方案设置
const Option = Select.Option;
// 方案下拉组件
const PlanSelect = ({
		tag,
		fundpool,
		dispatch,
}) => {
	// if(fundpool.Homestatus){
		const {
			filterList,
			sfkpiName ,
			sfschemeid,
			sfschemename,
			schemeId,
			benchmark,
			schemeName,
			pdtList,
			pdtList2
		} = fundpool;
		console.log("PlanSelect>>>",fundpool);
		const PlanSelectprops = {
			defaultValue: "请选择方案",
			data:filterList,
			onChange:(value)=>{
				console.log(`selected ${value}`);
				filterList.map((item)=>{
					if(item.schemeName == value){
						dispatch({
							type:`fundpool/getSchemekpi`,
							payload:{
								schemeId:item.schemeId,
								schemeName: item.schemeName,
							}
						})
						dispatch({
							type: `fundpool/setState`,
							payload: {
								schemeId:item.schemeId,
								beginDate:'',
								endDate:'',
								benchmark:'',
								timeRange:'7',
								establish:'',
					      fundS:'',
					      invest:'',
					      statusSs:'',
							}
						})
					}
				})
			},
			style:{width:130,marginLeft: 3}
		}
		
		const Benchmarkprops = {
			defaultValue: benchmark,
			data:pdtList?pdtList:[],
			onChange:(value)=>{
				console.log(`selected ${value}`);
				if(!_.isEmpty(pdtList)){
					pdtList.map((item)=>{
						if(item.productId == value){
							dispatch({
								type:'fundpool/setState',
								payload:{
									benchmark:value
								}
							})
						}
					})
				}
				
			},
			style:{width:130,marginLeft: 3}
		}
		console.log('Benchmarkprops>>>',Benchmarkprops)
		return (
			<div>
				<div className={style.plangroup}>
					<Row type="flex" justify="space-between" >
						<Col>
							<span style={{color:"black",fontSize:12}}>选择方案&nbsp;:&nbsp;&nbsp;&nbsp;</span>
							<Select {...PlanSelectprops} showSearch value={schemeName}>
								{
									PlanSelectprops.data.map((item,index) => <Option value={item.schemeName} key={item.schemeId}>{item.schemeName}</Option> )
								}
							</Select>
						</Col>
						<Col>
							<span style={{color:"black",fontSize:12}}>基准&nbsp;:&nbsp;&nbsp;&nbsp;</span>
							<Select {...Benchmarkprops} showSearch value={benchmark}>
								{
									Benchmarkprops.data?Benchmarkprops.data.map((item,index) => <Option value={item.productId} key={item.productId}>{item.productName}</Option> ):null
								}
							</Select>
						</Col>
						<Col className={style.schemefit}>
							<SchememFit
							  sfkpiName={sfkpiName}
							  sfschemeid={sfschemeid}
							  sfschemename={sfschemename}
							/>
						</Col>
					</Row>
				</div>
				<hr style={{marginTop:8,marginBottom:5}}/>
				<div>
					<SchemeSetup />
				</div>
			</div>
		)
	// }else{
	// 	return null;
	// }
}
PlanSelect.propTypes = {}

export default connect(({fundpool})=>({fundpool}))(PlanSelect)
